def compress(mystr):
    count, max_count, helper = 1, 0, []
    i, j = 0, 1
    while j < len(mystr):
        while j < len(mystr) and mystr[i] == mystr[j]:
            j += 1
            count += 1
        helper.append(mystr[i])
        helper.append(str(count))
        i = j
        j += 1
        max_count = max(max_count, count)
        count = 1
    if max_count > 1:
        return ''.join(helper)
    else:
        return mystr


mystr1 = ''
mystr2 = 'a'
mystr3 = 'aaaaa'
mystr4 = 'abcccddeefaaa'
print(compress(mystr1))
print(compress(mystr2))
print(compress(mystr3))
print(compress(mystr4))
